from rest_framework import serializers
from certificate_manager.models import News

class NewsSerializer(serializers.ModelSerializer):
        
        class Meta:
                model = News
                fields = ['pk', 'cate', 'title', 'url', 'img']

        def to_representation(self, news):
                ret = super().to_representation(news)
                ret['cate_name'] = news.cate.name
                ret['date'] = news.date
                return ret
